package com.itealabs.shao;

import java.io.File;
import java.io.IOException;

import com.itealabs.shao.core.ModuleManager;
import com.itealabs.shao.core.ModuleManagerClassLoader;

/**
 * BOOTSTRAP
 * @author itea
 * 2009-12-19
 * $Id: Bootstrap.java 68 2009-12-23 09:37:33Z iteahere $
 */
public class Bootstrap {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		ModuleManager mm = ModuleManagerClassLoader.bind2currentTherad();
		
		File f = null;
		for(String arg : args) {
			f = new File(arg);
			System.out.println(f.getAbsolutePath());
			if(!f.exists()) continue;
			if (f.isFile())
				try {
					mm.linkJar(f);
				} catch (IOException e) {
					e.printStackTrace(System.err);
				}
			else if(f.isDirectory()) {
				File[] fs = f.listFiles();
				for(File ff : fs)
					if(ff.getName().toLowerCase().endsWith(".jar"))
						try {
							mm.linkJar(ff);
						} catch (IOException e) {
							e.printStackTrace(System.err);
						}
			}
		}
	}
}
